package com.mpq.controler;

import com.alibaba.fastjson.JSON;
import com.mpq.entity.TestEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 整合rabbit
 * @author mingpingqiang on 2018/12/4/11:34
 * Created by mingpingqiang on 2018/12/4/11:34
 */
@RestController
@RequestMapping("/mpq/rabbit")
public class RabbitController {
    private static final Logger log = LoggerFactory.getLogger(RabbitController.class);
    private static final  String path = "C:\\Users\\11458\\Desktop\\";
    @Autowired
    private AmqpTemplate template;
    @RequestMapping("/send")
    public void send() {
        TestEntity user = new TestEntity();
        user.setOrderId("1234567890");
        user.setUsername("mpq");
        user.setPassword("123456");
        template.convertAndSend("queue", user);
        log.info(JSON.toJSONString(user));
    }
    @RequestMapping("/sendTopic")
    public void sendTopic() {
        TestEntity user = new TestEntity();
        user.setOrderId("1234567890");
        user.setPassword("123456");
        user.setUsername("mpq");
        template.convertAndSend("exchange","topic.mess", user);
        log.info(JSON.toJSONString(user));
    }
}
